//
//  BBTabView.m
//  xNose
//
//  Created by ben smith on 11.09.08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "BBTabView.h"
#import "BBImageButtonFactory.h"


@implementation BBTabView

- (id)initWithFrame:(NSRect)frame {
	self = [super initWithFrame:frame];
	if (self) {
		// Initialization code here.
		isOut = NO;
		// add the various views
		background = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"thinWithAlpha" ofType:@"png"]];
		stuckInX = NSMinX([self frame]);
		NSRect bRect = [self buttonRect];
		stuckOutX = stuckInX - (bRect.origin.x + 25);
		zoom = 1.0;
	}
	return self;
}

-(NSRect)buttonRect;
{
	return NSMakeRect(NSMinX(self.bounds) + 30 , 5, 40, 40);
}

-(float)buttonBorder;
{
	return 45.0;
}

-(void)zoomClick
{

	[[NSNotificationCenter defaultCenter] postNotificationName:@"BBZoomNotification" object:[NSNumber numberWithFloat:1.0]];
}

-(void)connectClick
{
	// turn on the connections
	[[NSNotificationCenter defaultCenter] postNotificationName:@"BBToggleConnected" object:self];
}

-(void)bulbClick
{
	[[NSNotificationCenter defaultCenter] postNotificationName:@"BBDiscloseConnected" object:self];
	[[NSNotificationCenter defaultCenter] postNotificationName:@"BBHighlightConnected" object:self];
}

- (void)drawRect:(NSRect)rect 
{
	NSSize iSize = [background size];
	[background drawInRect:NSMakeRect(0, 0, iSize.width, iSize.height) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:0.65];
}

-(void)mouseDown:(NSEvent*)theEvent
{
	NSRect f = [self frame];
	if (isOut) {
		f.origin.x = stuckInX;
		isOut = NO;	
	} else {
		isOut = YES;
		f.origin.x = stuckOutX;
	}
	[[self animator] setFrame:f];	
}

-(void)mouseDragged:(NSEvent*)theEvent
{	
}

-(void)mouseUp:(NSEvent*)theEvent
{
}

-(void)otherMouseDown:(NSEvent*)theEvent
{
	[self mouseDown:theEvent];
}

-(void)otherMouseUp:(NSEvent*)theEvent
{
}

-(void)otherMouseDragged:(NSEvent*)theEvent
{	
}



@end
